package exercise3;

import java.util.Arrays;

public class Exercise08_04 {
    public static void main(String []args)
    {
        int[][] workHours = {
                {2, 4, 3, 4, 5, 8, 8},
                {7, 3, 4, 3, 3, 4, 4},
                {3, 3, 4, 3, 3, 2, 2},
                {9, 3, 4, 7, 3, 4, 1},
                {3, 5, 4, 3, 6, 3, 8},
                {3, 4, 4, 6, 3, 4, 4},
                {3, 7, 4, 8, 3, 8, 4},
                {6, 3, 5, 9, 2, 7, 9}};


        //先计算每个员工的总工时
        int[] sum_hours=new int[8];//一共8个员工
        for (int i=0;i<8;i++)
        {
            for(int j=0;j<7;j++)
            {
                sum_hours[i]=sum_hours[i]+workHours[i][j];
            }
        }

        //再处理数组，将员工序号和工时放在同一个数组中
        for (int i=0;i<8;i++)//遍历数组
        {
            sum_hours[i]=sum_hours[i]*10+i;//十位数是工时，个位数是员工序号
        }

        //因为十位数表示工时，所以不影响排序结果
        Arrays.sort(sum_hours);

        //最后逆序输出
        for (int i=sum_hours.length-1;i>=0;i--)
        {
            System.out.println("Employee " + sum_hours[i]%10 + ": " +
                    sum_hours[i]/10);
        }
    }
}
